package com.lq.springai.controller;

import com.lq.springai.entity.ChatRequest;
import com.lq.springai.entity.ModelParams;
import com.lq.springai.service.ModelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.List;

@Slf4j
@Tag(name = "大模型对话接口")
@RestController
@CrossOrigin("*")
public class ChatbotController {

    @Resource
    private ModelService modelService;

    @Operation(summary = "文本对话")
    @PostMapping("/chat/aiTalk")
    public Flux<ServerSentEvent<String>> aiTalk(@RequestBody ChatRequest chatRequest){
        return modelService.aiModel(chatRequest);
    }

    @Operation(summary = "可支持的大模型列表")
    @PostMapping("/model/list")
    public List<ModelParams> modelList(){
        return modelService.modelList();
    }
}